home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / tview.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-07  |  2.4 KB  |  126 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1989, Tera Computer Company
  5.  **/
  6.  
  7.   /**
  8.      Implementation of text area. 
  9.      First line: graph name, file name
  10.      Second line: status
  11.    **/
  12.  
  13. #include "istring.h"
  14. #include "tview.h"
  15. #include <string.h>
  16. #include <InterViews/glue.h>
  17.  
  18. TextView::TextView (char* gname, char* fname) 
  19. {
  20.     line1 = new FirstLine(gname, fname);
  21.     line2 = new SecondLine("\0");
  22.     Init();
  23. }
  24.  
  25. void TextView::Init () 
  26. {
  27.     Insert(line1);
  28.     Insert(line2);
  29. }
  30.  
  31. void TextView::ChangeStatusLine (char* s, boolean now)
  32. {
  33.     line2->ChangeStatus (s);
  34.  
  35.       /**
  36.      unfortunately, this doesn't always work.  
  37.      See gframe.c for a solution 
  38.        **/
  39.     if (now)
  40.     {
  41.     Draw();
  42.     }
  43. }
  44.  
  45. void TextView::ChangeFileName (char* s) 
  46. {
  47.     line1->ChangeFileName (s);
  48.     Draw();
  49. }
  50.  
  51. void TextView::ChangeGraphName (char* s) 
  52. {
  53.     line1->ChangeGraphName (s);
  54.     Draw();
  55. }
  56.  
  57. FirstLine::FirstLine (char* g, char* f) 
  58. {
  59.     gname = new char[gmax + 1];
  60.     fname = new char[fimax + 1];
  61.  
  62.     strncpy (gname, g, gmax);
  63.     gmsg = new Message(strdup(gname));
  64.     gbox = new HBox();
  65.     gbox->Insert (new Message("Graph Name:  "));
  66.     gbox->Insert (gmsg);
  67.  
  68.     strncpy (fname, f, fimax);
  69.     fmsg = new Message(strdup(fname));
  70.     fbox = new HBox();
  71.     fbox->Insert (new Message("File:  "));
  72.     fbox->Insert (fmsg);
  73.  
  74.     Insert(gbox);
  75.     Insert(new HGlue);
  76.     Insert(fbox);
  77.     Insert(new HGlue);
  78. }
  79.  
  80. void FirstLine::ChangeGraphName (char* s) 
  81. {
  82.     strncpy (gname, s, gmax);
  83.     gbox->Remove(gmsg);
  84. //    delete gmsg;  
  85.       /**
  86.       this should work, but may not, and it's not that much 
  87.      space, anyway 
  88.        **/
  89.     gmsg = new Message(strdup(gname));
  90.     gbox->Insert(gmsg);
  91.     gbox->Change(gmsg);
  92. }
  93.  
  94. void FirstLine::ChangeFileName (char* s) 
  95. {
  96.     strncpy (fname, s, fimax);
  97.     fbox->Remove(fmsg);
  98. //    delete fmsg;    /* same here */
  99.     fmsg = new Message(strdup(fname));
  100.     fbox->Insert(fmsg);
  101.     fbox->Change(fmsg);
  102. }
  103.  
  104. SecondLine::SecondLine (char* s) 
  105. {
  106.     status = new char[smax + 1];
  107.  
  108.     strncpy (status, s, smax);
  109.     smsg = new Message(strdup(status));
  110.     sbox = new HBox();
  111.     sbox->Insert(new Message("Status:  ")); 
  112.     sbox->Insert(smsg);
  113.     Insert(sbox);
  114.     Insert(new HGlue);
  115. }
  116.  
  117. void SecondLine::ChangeStatus (char* s) 
  118. {
  119.     strncpy (status, s, smax);
  120.     sbox->Remove(smsg);
  121. //    delete smsg;    /* and here, and in many other places. */
  122.     smsg = new Message(strdup(status));
  123.     sbox->Insert(smsg);
  124.     sbox->Change(smsg);
  125. }
  126.